<template>
  <div class="container" >
    <div class="login-container">
      <Form id="loginForm" ref="loginForm" :model="form" :rules="rules">
        <FormItem prop="userName">
          <Input prefix="ios-contact-outline" size="large" v-model="form.userName" placeholder="请输入用户名" clearable/>
        </FormItem>
        <FormItem prop="userPassword">
          <Input prefix="ios-lock-outline" type="password" size="large" v-model="form.userPassword" placeholder="请输入密码" clearable/>
        </FormItem>
        <FormItem>
          <Button @click="handleSubmit" size="large" type="primary" long>登录</Button>
        </FormItem>
      </Form>
      <span class="foorter-copyright">Copyright © 2021 XXXX</span>
    </div>
  </div>
</template>


<script>
export default {
  data() {
    return {
      form: {},
      rules: {
        userName: { required: true, message: "用户名不能为空", trigger: "blur" },
        // userPassword: { required: true, message: "密码不能为空", trigger: "blur" },
      },
    };
  },
  methods: {
    handleSubmit() {
      this.$refs.loginForm.validate((valid) => {
        if (valid) {
          this.$store.dispatch("user/login", this.form).then((res) => {
            this.$router.push("/");
          });
        }
      });
    },
  },
};
</script>

<style scoped lang="less">
.container {
  height: 100%;
  background-image: url("../assets/login.jpg");
  background-size: cover;
  background-repeat: no-repeat;
  .login-container {
    width: 390px;
    margin: 0 auto;
    padding: 300px 0 0;
    button {
      font-size: 16px;
    }
    .foorter-copyright {
      color: #fff;
      text-align: center;
      position: absolute;
      left: 50%;
      bottom: 30px;
      transform: translateX(-50%);
    }
  }
}
</style>